<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('到货提醒列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="product-form">
                <div class="select-list">
                    <ul>
                        <!--<li>-->
                            <!--处理状态：<select name="status" th:with="type=${@dict.getType('remind_status')}">-->
                            <!--<option value="">全部</option>-->
                            <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                                    <!--th:value="${dict.dictValue}"></option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--是否有效：<select name="isEnable" th:with="type=${@dict.getType('is_enable')}">-->
                            <!--<option value="">全部</option>-->
                            <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                                    <!--th:value="${dict.dictValue}"></option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    const editFlag = [[${@permission.hasPermi('back:productStockRemind:edit')}]];
    const removeFlag = [[${@permission.hasPermi('back:productStockRemind:remove')}]];
    const remindStatusDict = [[${@dict.getType('remind_status')}]];
    const isEnableDict = [[${@dict.getType('is_enable')}]];
    const prefix = ctx + "back/productStockRemind";

    $(function () {
        var options = {
            url: prefix + "/searchList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            height: 600,
            sortName: "createTime desc,status asc,isEnable",
            sortOrder: "asc",
            modalName: "到货提醒",
            showColumns: false,
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'productName',
                    title: '商品名称',
                    sortable: true
                },
                {
                    field: 'productCoverUrl',
                    title: '商品图片',
                    formatter: function (value, row, index) {
                        let coverUrl = value;
                        if ($.common.isNotEmpty(row.skuCoverUrl)) {
                            coverUrl = row.skuCoverUrl;
                        }
                        return $.common.sprintf("<img class='img-circle img-sm' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s' data-src='%s'/>", 400, 'auto', 'self', coverUrl, coverUrl);
                    }
                },
                {
                    field: 'skuJson',
                    title: 'SKU规格',
                    sortable: true,
                    formatter: function (value, row, index) {
                        let skuName = "";
                        if ($.common.isNotEmpty(value)) {
                            let skuJsonData = JSON.parse(value);
                            for (let i = 0; i < skuJsonData.length; i++) {
                                skuName += skuJsonData[i].value
                            }
                        }
                        return skuName;
                    }
                },
                {
                    field: 'nickname',
                    title: '微信昵称',
                    sortable: true
                },
                {
                    field: 'phone',
                    title: '会员手机号',
                    sortable: true
                },
                {
                    field: 'avatar',
                    title: '会员头像',
                    formatter: function (value, row, index) {
                        return $.common.sprintf("<img class='img-circle img-sm' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s' data-src='%s'/>", 400, 'auto', 'self', value, value);
                    }
                },
                // {
                //     field: 'status',
                //     title: '处理状态',
                //     formatter: function (value, item, index) {
                //         return $.table.selectDictLabel(remindStatusDict, value);
                //     }
                // },
                // {
                //     field: 'isEnable',
                //     title: '是否有效',
                //     formatter: function (value, item, index) {
                //         return $.table.selectDictLabel(isEnableDict, value);
                //     }
                // },
                {
                    field: 'createTime',
                    title: '提醒时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit">编辑</i></a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>